package com.yangff.api.client;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yangff.api.client.fallback.UserClientFallbackFactory;
import com.yangff.entity.user.entity.User;
import com.yangff.entity.user.entity.UserAsset;
import com.yangff.entity.user.entity.dto.UserAssetDTO;
import com.yangff.entity.user.entity.dto.UserDTO;
import com.yangff.entity.user.entity.vo.UserAssetVo;
import com.yangff.entity.user.entity.vo.UserVo;
import com.yangff.entity.vo.ResultVo;
import com.yangff.utils.MathUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import java.security.NoSuchAlgorithmException;
import java.util.List;


@FeignClient(value = "user", fallbackFactory = UserClientFallbackFactory.class)
public interface UserClient {
    @PostMapping("/user")
    public UserVo saveUser(@RequestBody User user) throws NoSuchAlgorithmException;

    @GetMapping("/user")
    public List<User> selectUser();

    @GetMapping("/user/page")
    public Page<User> selectUserPage(@PageableDefault Pageable pageable);

    @PutMapping("/user/reset-status")
    public UserVo updateUserStatusByAccount(@RequestBody UserDTO userDTO);

    //按照账户查询用户信息
    @GetMapping("/user/{account}")
    public UserVo getUserByAccount(@PathVariable("account") String account);

    @DeleteMapping("/user/{account}")
    public ResultVo deleteUserByAccount(@PathVariable("account") String account);

    @PutMapping("/user/money")
    public UserVo updateUserFluidMoneyByAccount(@RequestBody UserDTO userDTO);

    //
    @PutMapping("/user")
    public UserVo updateUserByAccount(@RequestBody UserDTO userDTO);

    //单独改密码
    @PutMapping("/user/resetPassword")
    public UserVo updateUserPassword(@RequestBody UserDTO userDTO) throws NoSuchAlgorithmException;

    @PutMapping("/user/resetPaymentPassword")
    public UserVo updateUserPaymentPassword(@RequestBody UserDTO userDTO);

    @GetMapping("/user-asset/{code}")
    public List<UserAssetVo> getUserAssetByCode(@PathVariable("code") String code);

    @GetMapping("/user-asset/asset/{account}")
    public Page<UserAssetVo> getUserAssetByAccount(@PathVariable("account") String account, @PageableDefault Pageable pageable);

    @PutMapping("/user-asset")
    public UserAssetVo updateUserAssetByCode(@RequestBody UserAssetDTO userAssetDTO);

    @PostMapping("/user-asset")
    public UserAssetVo changeUserAssetAmount(@RequestBody UserAssetDTO userAssetDTO);

    @GetMapping("/user-asset/asset/{account}/all")
    public List<UserAssetVo> getAllUserAssetByAccount(@PathVariable("account") String account);

    @DeleteMapping("/user-asset/{code}")
    ResultVo deleteUserAssetByCode(@PathVariable("code") String code);

}